package com.crealth.db;

import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.List;
import com.crealth.manager.MybatisManager;
import com.crealth.model.StaffDayKPIModel;


public class StaffDayKPIDb {
	//private static Logger errorLog = Logger.getLogger("error_log");
	
	public static Integer insertUserDayCall(StaffDayKPIModel dayKpiModel) {
		Integer res = MybatisManager.dayKPIMapper.insertUserDayCall(dayKpiModel);
		MybatisManager.commit();
		
		return res;
	}
	
	public static List<StaffDayKPIModel> selectUserDayCall(String cdrTbName,
			String strDay) {
		List<StaffDayKPIModel> dayKpils = MybatisManager.dayKPIMapper.selectUserDayCall(cdrTbName, strDay);
		
		return dayKpils;
	}
	
	public static List<StaffDayKPIModel> selectUnderlingDayKPI(String ids, String searchDay) {
		List<StaffDayKPIModel> kpils = MybatisManager.dayKPIMapper.selectUnderlingDayKPI(ids, searchDay);
		
		return kpils;
	}
	
	public static List<StaffDayKPIModel> selectToDayKPI(String ids) {
		Date curd = new Date(System.currentTimeMillis());
		String strMonth = new SimpleDateFormat("yyyyMM").format(curd);
		String cdrTbName = "e_cdr_" + strMonth;
		String toDay = new SimpleDateFormat("yyyy-MM-dd").format(curd);
		List<StaffDayKPIModel> kpils = MybatisManager.dayKPIMapper.selectToDayKPI(ids, toDay, cdrTbName);
		
		return kpils;
	}
	
}
